<template>
	<view class="flex-col px-12 py-16 radius-12 bg-default fs-12 text-color-regular font-normal leading-22" @click="onClick">
		<vite class="text-color-regular fs-14 font-semibold leading-22 mb-8">经纪人推广权益</vite>
		<view v-if="(defaultCommissionType == 1 || defaultCommissionType == 2) && otherEquity" class="mt-4">
			<view class="item">可选权益一：佣金¥{{brokerage}}</view>
			<!-- <view class="item" v-else>可选权益一：佣金{{commissionRate}}%</view> -->
			<view v-if="otherEquity" class="item break-all">可选权益二：{{otherEquity}}</view>
		</view>
		<view v-else-if="(defaultCommissionType == 1 || defaultCommissionType == 2)" class="mt-4">
			<view class="item">佣金¥{{brokerage}}</view>
		</view>
		<view v-else>
			<view class="item break-all">{{otherEquity}}</view>
		</view>
	</view>
</template>

<script setup name="PromotionInterest">
	import { floorNumber } from '@/utils/index.js'
	import { ref, computed } from 'vue'
	const props = defineProps({
		commissionAmt: {
			type: Number
		},
		commissionRate: {
			type: [Number, String]
		},
		otherEquity: {
			type: String
		},
		defaultCommissionType: {
			type: [Number, String]
		},
		activePrice: {
			type: [Number, String]
		}
	})
	
	const emits = defineEmits(['click'])
	// 佣金
	const brokerage = computed(() => {
		return props.defaultCommissionType == 1 ? props.commissionAmt : props.defaultCommissionType === 2 ? floorNumber(props.activePrice * props.commissionRate / 100) : 0
	})
	const onClick = () => {
		if (props.commissionAmt && props.otherEquity) {
			emits('click')
		}
	}
</script>
